﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using BLL;


public partial class QuarterPlan_QuarterDateListAdd : System.Web.UI.Page
{
    QuarterDateManager dllQuarterDateManager = new QuarterDateManager();
    Authentication dllAuthentication = new Authentication();
    protected void Page_Load(object sender, EventArgs e)
    {
        dllAuthentication.isLogin();
        if (!IsPostBack)
        {
            #region 弹出提醒
            PopupManager dllPopupManager = new PopupManager();
            string _info = dllPopupManager.getPopupInfo();
            if (_info.Length > 0)
            {
                ShowMessage(_info);
            }
            #endregion
            bindDropDownList(drpYear1);
            bindGridViewQuarter(gdvQuarterList, drpYear1);
        }
    }

    /// <summary>
    /// 弹出小窗体事件
    /// </summary>
    /// <param name="msg"></param>
    public void ShowMessage(string msg)
    {
        EeekSoft.Web.PopupWin pop = new EeekSoft.Web.PopupWin();
        this.Controls.Add(pop);
        pop.Text = msg;
        pop.Message = msg;
        pop.Title = System.Configuration.ConfigurationManager.AppSettings["CompanyName"].ToString();
        pop.WindowScroll = true;
        pop.HideAfter = 99999999;
        pop.DockMode = EeekSoft.Web.PopupDocking.BottomLeft;
        pop.OffsetX = int.Parse(Session["_width"].ToString()) - 338;
        pop.ActionType = EeekSoft.Web.PopupAction.MessageWindow;
        pop.OffsetY = 1;
        pop.Width = 220;
        pop.Height = 170;
    }

    /// <summary>
    /// 绑定年份DropDownList
    /// </summary>
    /// <author>grokyao</author>
    /// <date>2009-1-12</date>
    void bindDropDownList(DropDownList _drp)
    {
        for (int i = 2009; i <= 2100; i++)
        {
            ListItem li = new ListItem(i.ToString());
            li.Value = i.ToString();
            _drp.Items.Add(li);
        }
    }
    /// <summary>
    /// 根据年份绑定年周期
    /// </summary>
    /// <param name="_gdvQuarter">要绑定的年GridView</param>
    /// <param name="_drpYear">获得年份的DropDownList</param>
    /// <author>grokyao</author>
    /// <date>2009-1-13</date>
    void bindGridViewQuarter(GridView _gdvQuarter, DropDownList _drpYear)
    {
        object[] _value = new object[1];
        _value[0] = _drpYear.SelectedValue;
        DataTable _quarter = dllQuarterDateManager.get(QuarterDateManager.field.QuarterYear.ToString(), _value);
        if (_quarter.Rows.Count != 0)
        {
            _gdvQuarter.DataSource = _quarter;
            _gdvQuarter.DataBind();
        }
        else
        {
            DataTable _empty = new DataTable();
            _gdvQuarter.DataSource = _empty;
            _gdvQuarter.DataBind();
        }
    }


    /// <summary>
    /// DropDownList索引改变事件
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    /// <author>grokyao</author>
    /// <date>2009-2-5</date>
    protected void drpYear1_SelectedIndexChanged(object sender, EventArgs e)
    {
        bindGridViewQuarter(gdvQuarterList, drpYear1);
    }
}
